package com.example.s.application;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.example.s.bean.User;
import com.orm.SugarContext;

public class MyApplication extends Application {
    private User user;
    private static MyApplication myApplication;
    private Context context;

    public MyApplication() {
    }

    private MyApplication(Context context) {
        this.context = context.getApplicationContext();
    }

    public static MyApplication getInstance(Context context) {
        if (myApplication == null) {
            synchronized (MyApplication.class) {
                if (myApplication == null) {
                    myApplication = new MyApplication(context);
                }
            }
        }
        return myApplication;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("MyApplication", "onCreate: ");
        SugarContext.init(this);
        initAppComponent();

    }


    @Override
    public void onTerminate() {
        super.onTerminate();
        SugarContext.terminate();
    }

    private void initAppComponent() {

    }


    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;

    }


}
